//
//  GAKKIBaseCollectionViewCell.m
//  GANGAIKit
//
//  Created by fh on 2019/11/6.
//  Copyright © 2019 cashchina. All rights reserved.
//

#import "GAKKIBaseCollectionViewCell.h"
#import "GAKKIConfig.h"

@interface GAKKIBaseCollectionViewCell ()
/// 初始化方法
/// @param frame 布局
- (instancetype)initWithFrame:(CGRect)frame;
@end

@implementation GAKKIBaseCollectionViewCell

#pragma mark - Public
+ (instancetype)dequeueReusableCellWithCollectionView:(UICollectionView *)collectionView indexPath:(nonnull NSIndexPath *)indexPath {
    return [self dequeueReusableCellWithCollectionView:collectionView reusableIdentifier:nil indexPath:indexPath];
}

+ (instancetype)dequeueReusableCellWithCollectionView:(UICollectionView *)collectionView reusableIdentifier:(NSString * _Nullable)identifier indexPath:(nonnull NSIndexPath *)indexPath {
    if (kStringIsEmpty(identifier)) {
        NSString *cellName = [NSString stringWithUTF8String:object_getClassName(self)];
        NSString *reuseIdentifier = [NSString stringWithFormat:@"%@ReuserIdentify",cellName];
        return [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
    }else {
        return [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    }
}

/// 配置子视图:子类实现
- (void)setupView {
    // 子类实现
    self.contentView.backgroundColor = [UIColor systemTealColor];
}

/// 清除所有子视图
- (void)cleanAllSubviews {
    for (UIView *subview in self.contentView.subviews) {
        [subview removeFromSuperview];
    }
}

#pragma mark - Life
/// 初始化方法
/// @param frame 布局
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupView];
    }
    return self;
}

- (void)dealloc {
    if (kDebugReusableViewRelease) {
#ifdef DEBUG
        DBLog(@"\n ----------- 可重用cell %@ 销毁了 ----------- \n",[self class]);
#endif
    }
}
@end
